﻿function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return decodeURIComponent(results[1].replace(/\+/g, " "));
}

function findFb() {
    var fbref = getParameterByName('fb_ref');
    var twitterref = getParameterByName('twitter_ref');
    if (fbref == 'top_like') {
        fbTrack('FBlikebuttonwall-web-event');
    }
    else if (fbref == 'ppshare') {
        fbTrack('FBpostpurchwall-web');
    }
    else if (fbref == 'HP_activity') {
        fbTrack2('FBActivityHPClick-Web');
    }
    else if (fbref == 'HP_recommendations') {
        fbTrack2('FBRecommendationHPClick-Web');
    }
    else if (fbref == 'postshare') {
        fbTrack('FBThankyoupageShareWall-web');
    }
    else if (twitterref == 'event') {
        fbTrack('TweetButtonWall-web-event');
    }
    else {
        '';
    }
}

function fbTrack(location) {
    s.linkTrackVars = 'eVar25';
    s.eVar25 = location;
    s.tl(this, 'o', 'FB Site Interaction');
}

function fbTrack2(location) {
    s.linkTrackVars = 'eVar59';
    s.eVar59 = location;
    s.tl(this, 'o', 'StubHub Site Social Interaction');
}

window.onload = findFb;
